home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gsmemret.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.6 KB  |  73 lines

  1. /* Copyright (C) 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gsmemret.h,v 1.2 2000/09/19 19:00:30 lpd Exp $ */
  20. /* Interface to retrying memory allocator */
  21.  
  22. #if !defined(gsmemret_INCLUDED)
  23. #  define gsmemret_INCLUDED
  24.  
  25. #include "gsmemory.h"
  26.  
  27. /*
  28.  * This allocator encapsulates another allocator with a closure that is
  29.  * called to attempt to free up memory if an allocation fails.
  30.  * Note that it does not keep track of memory that it acquires:
  31.  * thus free_all with FREE_ALL_DATA is a no-op.
  32.  */
  33. typedef struct gs_memory_retrying_s gs_memory_retrying_t;
  34.  
  35. /*
  36.  * Define the procedure type for the recovery closure.
  37.  */
  38. typedef enum {
  39.     RECOVER_STATUS_NO_RETRY,
  40.     RECOVER_STATUS_RETRY_OK
  41. } gs_memory_recover_status_t;
  42. typedef gs_memory_recover_status_t (*gs_memory_recover_proc_t)
  43.      (P2(gs_memory_retrying_t *rmem, void *proc_data));
  44.  
  45. struct gs_memory_retrying_s {
  46.     gs_memory_common;        /* interface outside world sees */
  47.     gs_memory_t *target;    /* allocator to front */
  48.     gs_memory_recover_proc_t recover_proc;
  49.     void *recover_proc_data;
  50. };
  51.  
  52. /* ---------- Public constructors/destructors ---------- */
  53.  
  54. /* Initialize a retrying memory manager. */
  55. int gs_memory_retrying_init(P2(
  56.             gs_memory_retrying_t * rmem,    /* allocator to init */
  57.             gs_memory_t * target    /* allocator to wrap */
  58.             ));
  59.  
  60. /* Release a retrying memory manager. */
  61. /* Note that this has no effect on the target. */
  62. void gs_memory_retrying_release(P1(gs_memory_retrying_t *rmem));
  63.  
  64. /* Set the recovery closure of a retrying memory manager. */
  65. void gs_memory_retrying_set_recover(P3(gs_memory_retrying_t *rmem,
  66.                        gs_memory_recover_proc_t recover_proc,
  67.                        void *recover_proc_data));
  68.  
  69. /* Get the target of a retrying memory manager. */
  70. gs_memory_t * gs_memory_retrying_target(P1(const gs_memory_retrying_t *rmem));
  71.  
  72. #endif /*!defined(gsmemret_INCLUDED) */
  73.